package com.fb;
import android.graphics.Bitmap;
import android.graphics.ImageDecoder;
import com.fb.FileItem;
import java.io.File;

class LoadGifIcon extends Thread {
    boolean map;
    File file;
    FileBrowserPage fbp;
    int index;
    LoadGifIcon(FileBrowserPage fbp,File file,int index){
        this.fbp=fbp;
        this.file=file;
        this.index=index;
    }
    @Override
    public void run(){
        super.run();
        ImageDecoder.Source imgs=ImageDecoder.createSource(file);
        try{
            final Bitmap bitmap= ImageDecoder.decodeBitmap(imgs);
            if(!interrupted()){
                fbp.ma.runOnUiThread(new Runnable(){
                        public void run(){
                            if(fbp.willshowSorted==null){
                                if(index<fbp.willshowLen){
                                    if(fbp.willshow[index]==file){
                                        fbp.willshowIcons[index]=bitmap;
                                    }
                                }
                            }else if(index<fbp.willshowSortedLen){
                                int maped=fbp.willshowSorted[index];
                                if(fbp.willshow[maped]==file){
                                    fbp.willshowIcons[maped]=bitmap;
                                }
                            }
                            fbp.atIconLoaderEnd(LoadGifIcon.this,index);
                        }
                    });
            }
        }catch(Exception e){
            fbp.ma.runOnUiThread(new Runnable(){
                @Override 
                public void run(){
                    if(fbp.willshowSorted==null){
                        if(index<fbp.willshowLen){
                            if(fbp.willshow[index]==file){
                                fbp.willshowIcons[index]=fbp.typeImageBroken;
                            }
                        }
                    }else if(index<fbp.willshowSortedLen){
                        int maped=fbp.willshowSorted[index];
                        if(fbp.willshow[maped]==file){
                            fbp.willshowIcons[index]=fbp.typeImageBroken;
                        }
                    }
                    fbp.atIconLoaderEnd(LoadGifIcon.this,index);
                }
            });
        }
    }
}
